#!/usr/bin/python
# -*- coding:utf-8 -*-

class Item:
    def __init__(self):
        self.id = -1
        self.child = {}


isbegin = True
datalist = []
k = 0
num = 0
def insert(item : Item, p : int, s : str, id : int):
    global  datalist
    P = item
    for each in s:
        if each not in P.child:
            P.child[each] = Item()
        P = P.child[each]
    if P.id == -1:
        P.id = id
    else:
        if p > datalist[P.id][0]:
            P.id = id


def search(item : Item, s : str) -> list:
    global isbegin
    P = item
    result = []
    for i in range(len(s)):
        if s[i] in P.child:
            P = P.child[s[i]]
        else:
            return result
    isbegin = True
    listget(result,P)
    return result


def listget(result : list, item : Item):
    global isbegin
    if isbegin:
        isbegin = False
    else:
        if item.id != -1:
            sort_insert(result, datalist[item.id])
    for each in item.child:
        listget(result, item.child[each])

def sort_insert(result : list, t : tuple):
    global k,num
    if num < k:
        now = num
    else:
        now = k
    equl = False
    while now > 0:
        if t[0] > result[now - 1][0] and not equl:
            now = now - 1
        else:
            if not equl:
                equl = True
            if t[0] == result[now - 1][0]:
                if t[1] < result[now - 1][1]:
                    now = now - 1
                else:
                    break
            else:
                break
        # elif t[1] < result[now - 1][1]:
        #     now = now - 1
        # else:
        #     break
    if now < k:
        num = num + 1
        result.insert(now,t)

if __name__ == '__main__':
    n, m, k = map(int,input().split())

    root = Item()

    for i in range(n):
        p, s = map(str,input().split())
        p = int(p)
        datalist.append((p,s))
        insert(root, p, s, i)

    ansdict = {}
    for i in range(m):
        flag = False
        key = input()
        time = 0
        if key in ansdict:
            if ansdict[key]:
                flag = True
                for s in ansdict[key]:
                        print(s)
                        time = time + 1
                        if time >= k:
                            break
        else:
            ans = []
            num = 0
            result = search(root,key)
            for t in result:
                if not flag:
                    flag = True
                print(t[1])
                time = time + 1
                ansdict[key] = [each[1] for each in result]
                if time >= k:
                    break

        if not flag:
            print('no suggestion')
        if i != m - 1:
            print()

